<?php


/**
 * Class FPString
 * time 2020/11/10 23:48
 * author zrone <xujining415@gmail.com>
 * copyright zrone <xujining415@gmail.com>
 */
class FPString
{
    /**
     * 生成UUID 单机使用
     * @param bool $separator
     * @return string
     */
    public static function uuid(bool $separator = true) : string
    {
        $charid = md5(uniqid(mt_rand(), true));
        $hyphen = $separator ? chr(45) : '';
        $uuid = substr($charid, 0, 8) . $hyphen
            . substr($charid, 8, 4) . $hyphen
            . substr($charid, 12, 4) . $hyphen
            . substr($charid, 16, 4) . $hyphen
            . substr($charid, 20, 12);
        return $uuid;
    }
}